package com.jetwinner.webfast.dbtool;

import javax.sql.DataSource;
import com.jetwinner.webfast.database.DatabaseDumper;
import com.jetwinner.webfast.database.FastDatabaseUtil;
import com.jetwinner.webfast.datasource.DataSourceConfig;

import java.sql.SQLException;

public interface DatabaseDumperProxy {

    static void addDumper(DataSource dataSource) throws SQLException {
        String dbType = dataSource.getConnection().getMetaData().getDatabaseProductName();
        if (DataSourceConfig.MYSQL_DB_TYPE.equalsIgnoreCase(dbType)) {
            DatabaseDumper dumper = new MySQLDumper(dataSource);
            FastDatabaseUtil.addDumper(FastDatabaseUtil.MYSQL_DUMPER_KEY, dumper);
        }
    }
}
